clear;
close all;
clc;

m = model('3e.model','linear=',true);
m = solve(m);
m = sstate(m);

%%
d = zerodb(m,1:40);
d.xxx = tseries(1:400,100);
d.epi(10) = 5i;
s = simulate(m,d,1:40,'deviation=',true,'dtrends=',true,'dboverlay=',~true);
c = simulate(m,d,1:40,'deviation=',true,'dtrends=',true,'dboverlay=',~true,'contributions=',true);

% dbplot(s,0:40,get(m,'xlist'),'tight=',true);

%%

b = bn(m,s,1:40,'deviation=',true,'dtrends=',true);

%%

d = resample(m,d,1:400,1,'deviation=',false,'dtrends=',true);

g = d * {'PI','R','xxx'};

%%
[~,f0] = filter(m,g,1:40,'deviation=',false,'meanOnly=',~true);

[~,f0d] = filter(m,g,1:40,'deviation=',true,'dtrends=',true,'meanOnly=',~true);

%%
v = struct();
v.epi = tseries(10,5i);
v.std_epi = tseries(10,0);
[~,f1] = filter(m,g,1:40,'deviation=',true, ...
    'meanOnly=',true,'vary=',v,'output=','pred');



